# Maintainer: Daniel M. Capella <polyzen@archlinux.org>
# Contributor: robertfoster
# Contributor: Ista Zahn <istazahn[at]gmail[dot]com>

_name=pyppeteer
pkgname=python-pyppeteer
pkgver=1.0.2
pkgrel=4
pkgdesc='Headless chrome/chromium automation library'
arch=('any')
url=https://github.com/pyppeteer/pyppeteer
license=('MIT')
depends=('python-appdirs' 'python-certifi' 'python-importlib-metadata'
         'python-pyee' 'python-tqdm' 'python-urllib3' 'python-websockets')
makedepends=('python-build' 'python-installer' 'python-poetry-core')
source=("$url/archive/$pkgver/$_name-$pkgver.tar.gz")
b2sums=('5e1581342e8b9cb65306a1bc2643262617bd5bf00cbb954935fcb8a35b9620bd750f809ce103582cba492d43dbf185eaa78b7b53b6194c30c136ed5a9a8dfaf0')

prepare() {
  cd $_name-$pkgver
  # Remove include list https://github.com/pypa/wheel/issues/92
  sed -i '/^include/,/]/d' pyproject.toml
}

build() {
  cd $_name-$pkgver
  python -m build --wheel --skip-dependency-check --no-isolation
}

package() {
  cd $_name-$pkgver
  python -m installer --destdir="$pkgdir" dist/*.whl

  # Symlink license file
  local site_packages=$(python -c "import site; print(site.getsitepackages()[0])")
  install -d "$pkgdir"/usr/share/licenses/$pkgname
  ln -s "$site_packages"/$_name-1.0.1.dist-info/LICENSE \
    "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
}
